package com.lottery.service.qiuqiu.accoutService;

import com.lottery.dao.qiuqiu.accoutDao.LoaclauthDao;
import com.lottery.dto.ResultDto;
import com.lottery.entity.Loaclauth;
import com.lottery.initData.InitData;
import com.lottery.service.qiuqiu.JedisClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class UserService {

    @Resource
    private JedisClient jedis;

    @Autowired
    private LoaclauthDao loaclauthdao;

    // 日志
    private final Logger logger = LoggerFactory.getLogger(this.getClass());


    public boolean checkUsername(String username) {
        Loaclauth user = loaclauthdao.selectphone(username);
        if (user == null) {
            return true;
        } else {
            return false;
        }
    }

    public void tourbetWaySwitch(Integer userId, Integer lotteyType,Integer loginType, ResultDto result)throws Exception {
        if(loginType == 1){
            jedis.hset(userId +"::"+lotteyType, "amount", 1000 + "");
            result.setResultData(true,"游客模式开启成功",0,null);
        }else{
            jedis.hdel(userId +"::"+lotteyType, "amount");
            result.setResultData(true,"关闭试玩模式成功",2,null);
        }
    }
}
